<div id="admin-products">

<h1 id="selectedCategory"><?php echo $title; ?></h1> <br>

<?php
if(count($products) > 0)
{
	echo '<table class="inventory-items table">';
	echo '<tr>';
	echo '<th>' . 'Kiemelt' . '</th>';
	echo '<th>' . 'Kép' . '</th>';
	echo '<th>' . 'Név' . '</th>';
	echo '<th class="description">' . 'Leírás' . '</th>';
	echo '<th class="netto_price">' . 'Netto ár' . '</th>';
	echo '<th class="price">' . 'Bruttó ár' . '</th>';
	echo '<th class="sell_price">' . 'Eladási ár' . '</th>';
	echo '<th class="profit_key">' . 'Haszon kulcs' . '</th>';
	echo '<th>' . 'Kategória' . '</th>';
	echo '<th>' . 'Muveletek' . '</th>';
	echo '</tr>';
} 

//KLogger::Instance()->LogDebug("products_view: " . var_dump($products));

foreach($products as $product) 
{
	$product = json_decode($product);
	//echo $product->{"name"};
	
	
	//$prod_category = $products_model->getCategory($product->category_id);
	$isFeatured = $product->isFeatured;
	if($isFeatured == 1) {
		$checkboxInputChecked = "checked";
	} else $checkboxInputChecked = "";
	
	echo '<tr>';
	echo '<td class="name"><input type="checkbox" '.$checkboxInputChecked.' value="'.$product->{"isFeatured"} . '" data-id="' . $product->{"id"} . '"></td>';
	echo '<td class="image"><img style="' . 'width: 50px;"' . 'src="'.base_url().'resources/products/' . $product->{"image"} . '" /></td>';
	echo '<td class="name">' . $product->{"name"} . '</td>';
	echo '<td class="description">' . $product->{"description"} . '</td>';
	echo '<td class="netto_price">' . $product->{"netto_price"} . '</td>';
	echo '<td class="price">' . $product->{"price"} . '</td>';
	echo '<td class="sell_price">' . $product->{"price"} *($product->{"profit_key"}/100+1) . '</td>';
	echo '<td class="profit_key">' . $product->{"profit_key"} . '</td>';
	echo '<td class="category">' . $product->{"o_cat_name"} . '</td>';
	echo '<td>'
	. '<a data-toggle="modal" data-id="' . $product->{"id"} . '" class="product-delete-link" href="#removeConfirmation">'
	. 	'<button type="button" class="btn btn-default btn-danger"><span class="glyphicon glyphicon-remove"></span> Törlés</button>'
	. '</a>'
	. '<a data-toggle="modal" data-id="' . $product->{"id"} . '" class="product-edit-link">'
	. 	'<button type="button" class="btn btn-default btn-warning"><span class="glyphicon glyphicon-pencil"></span> Módosítás</button></a>' 
	. '</a>'
	. '</td>';			
	echo '</tr>';
	
}
echo '</table>';
?>
</div>